const send = require('koa-send');
const router = require('koa-router')()
const fileUploader = require('../libs/FileUploadHelper');

router.get('/', async (ctx, next) => {
  await send(ctx, 'index.html');
});
 
router.get('/demo/upload', async(ctx, next)=>{
  await ctx.render('demo/upload');
});

router.post('/demo/saveFile', async(ctx, next)=>{
  let files =  fileUploader.upload(ctx);

  await (ctx.body = JSON.stringify(files));
});

module.exports = app => {
  app.use(router.routes(), router.allowedMethods());

  return router;
};